home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #036 (1990)(Amiga User Group Deutschland e.V.).zip / Franz PD Disk #036 (1990)(Amiga User Group Deutschland e.V.).adf / SPRITESinACTION / Demo.c < prev    next >
C/C++ Source or Header  |  1989-07-02  |  3KB  |  90 lines

  1. /* Demo fuer Sprites in Action V1.2 */
  2. /* (C) in 1989 by G.A.P             */
  3.  
  4. /* fuer Aztec-C V3.6  */
  5. /* cc Demo.c -s +l    */
  6. /* ln Demo.o -lc32    */
  7.  
  8.  
  9. #include <intuition/intuition.h>
  10. #include <intuition/intuitionbase.h>
  11. #include <libraries/dos.h>
  12. #include <graphics/gfxmacros.h>
  13. #include <graphics/sprite.h>
  14. #include <exec/types.h>
  15. #define VP &Screen->ViewPort
  16.  
  17. struct Screen *Screen;
  18. struct IntuitionBase *IntuitionBase;
  19. struct GfxBase *GfxBase;
  20. struct FileName *Fhandle;
  21.  
  22. USHORT S_Height[1],Anim_Strt[1],Anim_Stop[1],
  23.        r[3],g[3],b[3],
  24.        Sprites[16][68],num=2,C_Sprites;
  25. struct SimpleSprite sprite={Sprites[0],32};
  26.  
  27. main()
  28. {
  29.  OpenLib();                 /* Libs oeffnen */
  30.  Screen = IntuitionBase->ActiveScreen;
  31.  GetSprite(&sprite,num);    /* Sprite 2 aktivieren */   
  32.  Load_Sprite();             /* Daten laden */
  33.  FreeSprite(num);           /* Sprite loeschen */
  34.  ;                /* Libs schliessen */
  35. }
  36.  
  37. OpenLib()
  38. {
  39.  if(!(IntuitionBase=(struct IntuitionBase *)
  40.    OpenLibrary("intuition.library",0))){
  41.    CloseLib();
  42.  }
  43.  if(!(GfxBase=(struct GfxBase *)
  44.    OpenLibrary("graphics.library",0))){
  45.    CloseLib();
  46.  }
  47. }
  48.  
  49. CloseLib()
  50. {
  51.  if(IntuitionBase) CloseLibrary(IntuitionBase);
  52.  if(GfxBase)       CloseLibrary(GfxBase);
  53. }
  54.  
  55. Load_Sprite()
  56. {
  57.  USHORT i,j;
  58.  Fhandle=Open("Man.dat",MODE_OLDFILE); /* hier Filename der      */
  59.  if(Fhandle==0) return();                   /* Animationsdatei eintragen */
  60.  Read(Fhandle,S_Height,2);                  /* Hoehe      lesen */
  61.  Read(Fhandle,Anim_Strt,2);                 /* Startphase l.    */
  62.  Read(Fhandle,Anim_Stop,2);                 /* Stopphase  l.    */
  63.  Read(Fhandle,r,6);                         /* 3 Rot-Anteile l. */
  64.  Read(Fhandle,g,6);                         /* 3 Gruen-A. l.    */
  65.  Read(Fhandle,b,6);                         /* 3 Blau-A. l.     */
  66.  j=Anim_Strt[0];
  67.  C_Sprites=Anim_Stop[0]-Anim_Strt[0];       /* Anzahl der Phasen */
  68.  for(i=0;i<(C_Sprites+1);i++)
  69.  {
  70.   Read(Fhandle,Sprites[i],4*S_Height[0]+8); /* Daten lesen */
  71.  }
  72.  Close(Fhandle);
  73.  for(i=0;i<4;i++) SetRGB4(VP,i+21,r[i],g[i],b[i]); /* Farbreg. setzen */
  74.  Animation();                                      /* Animation starten */
  75. }
  76.  
  77. Animation()
  78. {
  79.  USHORT i,x,y;
  80.  y=100;                              /* y-Koordinate */
  81.  for(x=0;x<640;x+=2)                 /* x-Bewegung von 0 bis 640 */
  82.  {
  83.   MoveSprite(VP,&sprite,x,y);
  84.   ChangeSprite(VP,&sprite,Sprites[i]); /* naechste Phase */
  85.   i++;
  86.   if(i>C_Sprites) i=0;
  87.   Delay(3);                            /* warten */
  88.  }
  89. }
  90.